package com.ruoyi.project.notice.statistics.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.notice.manager.domain.NoticeManager;
import com.ruoyi.project.notice.manager.service.NoticeManagerService;
import com.ruoyi.project.notice.statistics.service.NoticestatisticsService;
import com.ruoyi.project.notice.type.service.NoticeTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/notice/statistics")
public class NoticestatisticsController extends BaseController {

    @Autowired
    private NoticeManagerService noticeManagerService;

    @Autowired
    private NoticeTypeService noticeTypeService;

    @Autowired
    private NoticestatisticsService noticestatisticsService;

    String prefix = "notice/statistics";

    @GetMapping()
    public String notice() {
        return prefix + "/statistics";
    }

    @PostMapping("list")
    @ResponseBody
    public TableDataInfo managerList(NoticeManager noticeManager) {
        startPage();
        List<NoticeManager> noticeManagers = noticeManagerService.selectAll(noticeManager);
        return getDataTable(noticeManagers);
    }

    /**
     * 查看
     * @return
     */
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") Long id, ModelMap mmap){

        NoticeManager noticeManager = noticeManagerService.selectTypeById(id);

        noticestatisticsService.updateById(noticeManager);
        mmap.put("manager",noticeManager);
        return prefix + "/details";
    }




}
